package com.jasonflaherty.inciweb;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.androidquery.AQuery;

public class SingleIncident extends SherlockActivity {
	private AQuery aq;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		aq = new AQuery(this);
		setContentView(R.layout.single_list_item_view);
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
		getSupportActionBar().setSubtitle("Lastest Information...");
		// TextView title = (TextView) findViewById(R.id.title);
		// TextView published = (TextView) findViewById(R.id.published);
		// TextView link = (TextView) findViewById(R.id.link);
		//
		// link.setMovementMethod(LinkMovementMethod.getInstance());
		//
		// TextView description = (TextView) findViewById(R.id.description);
		// TextView geoLat = (TextView) findViewById(R.id.geoLat);
		// TextView geoLon = (TextView) findViewById(R.id.geoLon);
		// TextView geoLatLon = (TextView) findViewById(R.id.geoLatLon);

		Bundle extras = getIntent().getExtras();
		if (extras != null) {
			aq.id(R.id.title).text(extras.getString("title"));
			aq.id(R.id.description).text(extras.getString("desc"));
			aq.id(R.id.link).text(extras.getString("link"));
		}

	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
		inflater.inflate(R.menu.main, (com.actionbarsherlock.view.Menu) menu);
		return super.onCreateOptionsMenu(menu);
	}
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle item selection
		switch (item.getItemId()) {
		case android.R.id.home:
			Log.i("MENU", "Home Clicked");
			Intent intentHome = new Intent(getBaseContext(), MainActivity.class);
			intentHome.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
					| Intent.FLAG_ACTIVITY_NO_ANIMATION);
			startActivity(intentHome);
			return true;
		case R.id.map:
			Log.i("MENU", "MAP Clicked");
			Intent map = new Intent(getBaseContext(),
					InciwebMapActivity.class);
			map.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
					| Intent.FLAG_ACTIVITY_NO_ANIMATION);
			startActivity(map);
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}
}